}
// processing the custom build script
- let new_build = self.maybe_custom_build(&project.build, &layout.root);
+ let new_build = self.maybe_custom_build(&project.build, &layout.root, &mut warnings);
// Get targets
let targets = normalize(&lib,
Ok(replace)
}
- fn maybe_custom_build(&self, build: &Option<StringOrBool>, project_dir: &Path)
+ fn maybe_custom_build(&self,
+ build: &Option<StringOrBool>,
+ project_dir: &Path,
+ warnings: &mut Vec<String>)
-> Option<PathBuf> {
let build_rs = project_dir.join("build.rs");
match *build {
Some(StringOrBool::String(ref s)) => Some(PathBuf::from(s)),
None => {
match fs::metadata(&build_rs) {
- Ok(ref e) if e.is_file() => Some(build_rs.into()),
+ // Enable this after the warning has been visible for some time
+ // Ok(ref e) if e.is_file() => Some(build_rs.into()),
+ Ok(ref e) if e.is_file() => {
+ warnings.push("`build.rs` files in the same directory \
+ as your `Cargo.toml` will soon be treated \
+ as build scripts. Add `build = false` to \
+ your `Cargo.toml` to prevent this".into());
+ None
+ },
Ok(_) => None,
Err(_) => None,
}
authors = []
"#)
.file("src/main.rs", r#"
+ use std::path::Path;
fn main() {
- println!(include_str!(concat!(env!("OUT_DIR"), "/output")));
+ let f = env!("OUT_DIR");
+ assert!(
+ ! Path::new(f).join("output").exists()
+ );
}
"#)
.file("build.rs", r#"
p.build();
assert_that(p.cargo("run").arg("-v"),
- execs().with_status(0).with_stdout("foo\n"));
+ execs().with_status(0).with_stderr("\
+warning: `build.rs` files in the same directory as your `Cargo.toml` will soon be treated \
+as build scripts. Add `build = false` to your `Cargo.toml` to prevent this
+ Compiling builder v0.0.1 ([..])
+ Running [..]
+ Finished [..]
+ Running [..]
+"));
}
#[test]